/**
 * Created by fangshufeng on 2017/11/17.
 */
var express = require('express');
var router = express.Router();
var  mysql = require('mysql');

router.get('/', function(req, res, next) {

    var connection = mysql.createConnection({
        host : 'localhost' ,
        user : 'root' ,
        password : '123456' ,
        database : 'mock_db',
    });
    connection.connect(function(err) {
        if (!err) {
            var selectSql = "SELECT * FROM mock_db.testTable where user_name='zhangsan'";
            var  user_name ;
            connection.query(selectSql, values = {} ,function (err,resp) {
                if (err) {
                    res.send(err);
                }else  {
                    res.json(values);
                }
            });
        }
        connection.end();
    });

});

module.exports = router;